package com.zhu.service;

import com.zhu.mapper.OrderMapper;
import com.zhu.pojo.Order;
import com.zhu.pojo.Person;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;

    public Map<String,Object> getOrderStatistics(){return orderMapper.getOrderStatistics();}

    public List<Order> unassigned(){
        List<Order> list =  orderMapper.unassigned();
        for(Order order :list){
            order.setBusiness_name(orderMapper.getbusname(order.getBusiness_id()));
            order.setPersonnel_name(orderMapper.getpername(order.getPersonnel_id()));
        }
        return list;
    }

    public List<Person> perlist(){
        return orderMapper.perlist();
    }

    public void paidan(Integer business_id,Integer personnel_id){
        orderMapper.paidan(business_id,personnel_id);
    }
    public List<Order> assigned(){
        List<Order> list =  orderMapper.assigned();
        for(Order order :list){
            order.setBusiness_name(orderMapper.getbusname(order.getBusiness_id()));
            order.setPersonnel_name(orderMapper.getpername(order.getPersonnel_id()));
        }
        return list;
    }

    public void shoudan(Integer id){
        orderMapper.shoudan(id);
    }
}
